package com.czkt.springboot_mybatis_test.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.czkt.springboot_mybatis_test.entity.BasDict;
import com.czkt.springboot_mybatis_test.entity.vo.CstCustomerBasDict;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-06-18
 */
@Mapper
public interface BasDictMapper extends BaseMapper<BasDict> {
    @Select("select count(*) from bas_dict where dict_id like concat('%',#{dictId},'%') and dict_item like concat('%',#{dictItem},'%')")
    Integer selectBasDictCount(@Param("dictId")String dictId,@Param("dictItem")String dictItem);

    @Select("select * from bas_dict where dict_id like concat('%',#{dictId},'%') and dict_item like concat('%',#{dictItem},'%') limit #{pageIndex},#{pageSize};")
    List<BasDict> selectBasDictList(@Param("dictId")String dictId,@Param("dictItem")String dictItem,@Param("pageIndex")Integer pageIndex,@Param("pageSize") Integer pageSize);

    @Select("select * from bas_dict where dict_id = #{dictId};")
    BasDict selectBasDict(String dictId);

    @Select("update bas_dict set dict_item=#{dictItem} where dict_id=#{dictId};")
    void toUpdateBasDict(BasDict basDict);

    @Select("delete from bas_dict where dict_id = #{dictId};")
    void deleteBasDict(String dictId);

    @Select("insert into bas_dict ( dict_type, dict_item, dict_value) values (#{dictType},#{dictItem},#{dictItem});")
    void toInsertBasDict(BasDict basDict);

    @Select("select * from bas_dict where dict_type = '地区';")
    List<BasDict> selectByDictType();
}
